<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>094-追加节点.html</title>
</head>
<body>
	<ul id="ul1">
		<li>1</li>
		<li>399</li>
		<li>3</li>
		<li>53</li>
		<li>8</li>
		<li>6</li>
	</ul>
	<input type="button" id="btn" value="排序">
</body>
<script>
	var oUl = document.getElementById('ul1');
	var oBtn = document.getElementById('btn');
	oBtn.onclick = function(){
		var aLi = oUl.children;
		var aEle = [];
		// console.log(aLi);
		for(var i = 0;i<aLi.length;i++){
			aEle.push(aLi[i]);
		}
		aEle.sort(function(oLi1,oLi2){
			return oLi1.innerHTML - oLi2.innerHTML;
		});
		
		for(var i = 0;i<aEle.length;i++){
			oUl.appendChild(aEle[i]);
		}
	} 
</script>
</html>